package com.hrzyit.whistle.user.presenter

import com.hrzyit.base.ext.execute
import com.hrzyit.base.presenter.BasePresenter
import com.hrzyit.base.rx.BaseObserver
import com.hrzyit.whistle.user.data.bean.UserInfo
import com.hrzyit.whistle.user.presenter.view.ResetPwdView
import com.hrzyit.whistle.user.service.IUserService
import javax.inject.Inject

/**
 * Presenter: 用户个人信息
 * @author YangWei
 * @date 2019/3/24
 */
class ResetPwdPresenter @Inject constructor() : BasePresenter<ResetPwdView>() {

    // Dagger2 注入 IUserService
    @Inject
    lateinit var userService: IUserService

    /**
     * 重置密码
     * @param mobile   手机号
     * @param newPwd   新密码
     * @param pushId   极光帐号id
     */
    fun resetPwd(mobile: String, newPwd: String) {
        if (!checkNetWork()) {
            return
        }
        // 执行完成回调
        mView.showLoading()

        userService.resetPwd(mobile, newPwd)
            .execute(object : BaseObserver<UserInfo>(mView) {
                override fun onNext(t: UserInfo) {
                    mView.onResetPwdResult(t)
                }
            }, lifecycleProvider)
    }

}